
<?php

  if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
    $new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
  } else {
    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
  }
$listing_split = new splitPageResults($new_products_query, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

$products_query = tep_db_query($listing_split->sql_query);

  
$i = 1;
$k = 0;

if ($listing_split->number_of_rows > 0)
    echo '<p class="marginT10">'. TEXT_DISPLAY_NEW_PRODUCTS .'. '. $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS) . '</p>';

echo '<div class="clear marginT10">';
if (tep_db_num_rows($products_query) > 0) {
    while ($products = tep_db_fetch_array($products_query)) {
        if ($k % 5 == 0 && $k > 0) {
            echo '</div><div class="clear marginT10">';
            $i = 1;
        }

        if ($i == 1)
            $css = 'item1';
        else if ($i == 2)
            $css = 'item2';
        else if ($i == 3)
            $css = 'item3';
        else if ($i == 4)
            $css = 'item4';
        else
            $css = 'item5';

        echo '<div class="' . $css . '">
						<table border="0" cellpadding="0" cellspacing="0" width="100%">
							<tr><td style="padding-top: 10px;"></td></tr>
							<tr>
								<td align="center"><a href="' . tep_href_link('product_info.php', 'products_id=' . $products['products_id']) . '"> <img src="images/' . $products['products_image'] . '" alt="" border="0px"/></a></td>
							</tr>
							<tr><td style="padding-top: 10px;"></td></tr>
							<tr>
								<td><strong><a href="' . tep_href_link('product_info.php', 'products_id=' . $products['products_id']) . '">' . $products['products_name'] . '</a></strong></td>
							</tr>
							<tr>
								<td>' . substr($products['products_description'], 0, 50) . '...</td>
							</tr>
							<tr>
								<td><div id="price"><p>' . $currencies->display_price($products['products_price'], tep_get_tax_rate($products['products_tax_class_id'])) . ' <a href="' . tep_href_link('index.php', 'cPath=' . $current_category_id . '&action=buy_now&products_id=' . $products['products_id']) . '"><img src="pub/images/icon_basket.gif" border="0"  align="center"/></a></p></div></td>
							</tr>
						</table>

					</div>';
        $i++;
        $k++;
    }
}
else {
    echo '<div style="padding: 1px 0px 20px 0px;">'. TEXT_DISPLAY_NO_PRODUCT .'</div>';
}
echo '</div>';

if ($listing_split->number_of_rows > 0) {
    echo '<div class=" clear"></div>
			            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="marginT10">
				 	<tr><td colspan="2" style="height: 10px;"></td></tr>
					<tr>
						<td align="left">' . $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS) . '</td>
						<td align="right">' . TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))) . '</td>
					</tr></table>';
}
?>
<!-- new_products_eof //-->
